/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lab9;
/**
*
* @author mweya
*/
public class Lab9 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String[] names = {"John","Jane","Jon't", "Jo-Anne","Joe","James","Jamison","Jeremy","Jerome","Janice"};
try{
int j = 0;
while (j<names.length){
System.out.println(names[j]);
j++;
}
Thread.sleep(5000);
}
catch(InterruptedException e) {
System.err.println(e.toString());
}
System.out.println("Starting threads");
(new Thread(new First())).start();
(new Thread(new First())).start();
(new Thread(new Second())).start();
(new Thread(new Second())).start();
// Thread manipulation starts here
try {
// Make thread sleep for 1 second and 1 millisecond
Thread.sleep(1000, 1000);}
catch(InterruptedException e) {
System.err.println(e);
}
// Make a thread wait for another to die
Thread t1 = new Thread(new First());
try {
t1.join();
}
catch (InterruptedException e) {
System.err.println(e);
}
// Interrupt a thread
t1.interrupt();
}
}